﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Common;

namespace Tedu.ARPGDemo.Character
{
	/// <summary>
    /// 角色选择器
    /// </summary>
	public class CharacterSelected : MonoBehaviour {
        public string selectedName = "selected";
        public float disPlayTime = 5;
        private GameObject selectGo;
        private float hideTimer;
        private void Start()
        {
            selectGo = transform.FindChaildByName(selectedName).gameObject;
        }
        /// <summary>
        /// 设置选择器显隐状态
        /// </summary>
        /// <param name="state"></param>
        public void SetSelectedActive(bool state)
        {
            selectGo.SetActive(state);
            enabled = state;//enabled控制组件的显示隐藏;备注：脚本禁用，Update不执行
            if (state)
            {
                hideTimer = Time.time + disPlayTime;
            }
        }
        private void Update()
        {
            if (hideTimer <= Time.time)
            {
                SetSelectedActive(false);
            }
        }
    }
}

